//
//  InnerViewController.m
//  Ghac 4S
//
//  Created by apple on 11-11-8.
//  Copyright (c) 2011年 __MyCompanyName__. All rights reserved.
//
#import "Global.h"
#import "InnerViewController.h"
#import "InnerViewAction.h"

@interface InnerViewController(private) 
-(void) setUpBottomBar;
@end

@implementation InnerViewController
@synthesize contentViewContainer;
@synthesize innerViewController;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self)
    {
        m_innerViewController = nil;
    }
    return self;
}
-(void)dealloc
{
    KRELEASE(m_innerViewController);
    [super dealloc];
}
-(void)setInnerViewController:(UIViewController<InnerViewAction>*)contentViewController
{
    if (m_innerViewController != nil)
    {
        UIView* oldView = m_innerViewController.view;
        [oldView removeFromSuperview];
    }
    KRELEASE(m_innerViewController);
    m_innerViewController = [contentViewController retain];
    [self.contentViewContainer addSubview:m_innerViewController.view];
    
}
-(UIViewController<InnerViewAction>*)innerViewController
{
    return [[m_innerViewController retain] autorelease];
}
-(void)setUpBottomBar
{
    
}
- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

-(void)backBtnClick:(id)sender
{
//    NSLog(@"ha");
    if ([self.innerViewController respondsToSelector:@selector(backBtnClick:)])
    {
        [self.innerViewController performSelector:@selector(backBtnClick:) withObject:sender];
        return;
    }
    
    id<MainViewSwitchAction> target = [Global mainRootController];
    [target backToEntryView];
}
#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
    [self.contentViewContainer release];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
